﻿@model ThaireInvestmentWeb.Models.AddDepositInterestModel
@{
    ViewBag.Title = "AmortizeSchedule";
}
<script>
    $(document).ready(function () {

        $("#ApplyDate").datepicker(
            {
                dateFormat: 'dd/mm/yy',
                showOn: 'button',
                showAnim: 'fadeIn',
                changeMonth: true,
                changeYear: true,
                showButtonPanel: true,
                buttonImage: '@Url.Content("~/Content/images/Calendar.png")'
            });
        
       
        

        $("#CancelBtn").click(function (event)
        {
           
            showConfirm(null, CancelBtnAction);
            return false;
        });
        function CancelBtnAction(event)
        {
            
            window.location.href= 'EditDepositHeader?headerId=@Model.HeaderID';
        }

    });
   
        function del(key)
        {
            showConfirm("ต้องการลบหรือไม่ ?", function ()
            {
                window.location.href= 'DeleteDepositInterest?interestId='+key;
                closeConfirm();
            });
            return false;

        }
    
    
</script>


<table class="navi" width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
    <tr>
        <td style="width: 100%;">
            <div class="navi">
                Instrument Type > <a href="@Url.Action("ManageDeposit", "Deposit", new { headerId = @Model.HeaderID })">Deposit at Financial Institutions</a> > <a href="@Url.Action("EditDepositHeader", "Deposit", new { headerId = Model.HeaderID })">Header</a> > Interest Rate
          
            </div>
        </td>
    </tr>
</table>


<table class="tableheader" width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
    <tr>
        <td height="38" align="center" style="width: 100%; text-align: center;">Interest Rate : Deposit</td>
    </tr>
</table>
<table width="951" border="1" align="center">
    <tr>
        <td>

            @using (Html.BeginForm("EditInterestRate", "Deposit", FormMethod.Post, new { id = "mainForm" }))
            {
                <div style="width: 100%;" align="center">
                    <div style="width: 550px; border: 1px; overflow: auto;">
                        <table align="center" cellspacing="2">
                            <tr>
                                <th colspan="3"><strong>Add Interest Rate : Deposit</strong></th>


                            </tr>
                            <tr>
                                <td width="212">
                                    <div align="right">Apply Date : <span class="error">*</span></div>
                                </td>
                                <td width="8">&nbsp;</td>
                                <td>
                                    @Html.TextBoxFor(x => x.ApplyDate, new { @readonly = "readonly", @value = ThaireInvestmentWeb.Util.WebUtil.FormatDate(Model.ApplyDate) })
                                    @Html.ValidationMessageFor(model => model.ApplyDate)
                                </td>

                            </tr>
                            <tr>
                                <td width="212">
                                    <div align="right">Interest Rate : <span class="error">*</span></div>
                                </td>
                                <td width="8">&nbsp;</td>
                                <td>
                                    @Html.TextBoxFor(x => x.InterestRate, new { @class = "inputNumberField" })
                                    @Html.ValidationMessageFor(model => model.InterestRate)

                                </td>

                            </tr>
                            <tr>
                                <td colspan="3">
                                    <div align="center">

                                        <input id="SubmitBtn" type="submit" name="BtnSubmit" value=" Submit " class="button" need-confirm="true">
                                        &nbsp;&nbsp; 
                                    &nbsp;&nbsp; 
                                    <input id="CancelBtn" type="button" name="CancelBtn" value=" Cancel " class="button">
                                    </div>
                                </td>
                            </tr>
                        </table>



                        <br />
                        <br />

                        @if (Model.InterestAdaters != null && Model.InterestAdaters.Count > 0)
                        {
                            var grid = new WebGrid(source: Model.InterestAdaters, ajaxUpdateContainerId: "gridselected", rowsPerPage: 25, canSort: false);
                            @grid.GetHtml(htmlAttributes: new { id = "gridselected" }, tableStyle: "tablelist", headerStyle: "headertable", displayHeader: @Model.InterestAdaters.Count > 0,
            columns: grid.Columns(

                grid.Column(header: "NO.", format: item => (item.WebGrid.Rows.IndexOf(item) + 1) + (grid.PageIndex * grid.RowsPerPage), canSort: false),
                grid.Column(header: "Apply Date", format: @<text> @ThaireInvestmentWeb.Util.WebUtil.FormatDate(item.ApplyDate) </text>),
                grid.Column(header: "Interest Rate (%)", style: "columnNumber", format: @<text> @ThaireInvestmentWeb.Util.WebUtil.FormatDecimal2Digit(item.InterestRate) </text>),
                grid.Column(header: "ลบ", canSort: false, format: @<text>
                            <input type="image" id="BtnDelete"  = true name="BtnDelete"  onclick="return del('@item.InterestID    ')"  value="@item.InterestID" src="@Url.Content("~/Content/images/delete.png")"  title="ลบ"></text>)

                        ));


                        }
                        @*
                        else
                        {                    
                            <table align="center" border="0" width="100%">
                                <tr>
                                    <td style="text-align: center"><span class="error">ไม่พบข้อมูล</span></td>
                                </tr>
                            </table>
                        }*@


                    </div>
                </div>
                <a name="grid-anchor"></a>
                <script type="text/javascript">
                    $(function () {
                        $('th a, tfoot a').live('click', function () {
                            $(this).attr('href', '#grid-anchor');
                        });
                    });
                </script>
                
                @Html.HiddenFor(x => x.HeaderID);
                @Html.HiddenFor(x => x.DeleteID);
            }

            <br>
        </td>
    </tr>
</table>





